#!/usr/bin/env python
#-*-encoding:utf-8-*-
'''
Created on 2014年10月16日

@author: chenyongbing
'''
import ConfigParser,os,re
import base64
import sys
current_dir = os.path.split(os.path.realpath(__file__))[0]
sys.path.append('../../')
from base.localConfig import LocalConfig
class LocalConfig(LocalConfig):
    '''
    classdocs
    '''


    def __init__(self, config_file=None):
        self.config = ConfigParser.SafeConfigParser()
        self.get_export_rule()
        
   
    
    def analyze_value(self,option,value):
        if option=='maxbytes':
            value = eval(value)
        
        elif option=='passwd':
            value = self.analysis_passwd(value)
        elif re.search('_path|_file',option):
            value = os.path.join(current_dir,value)
        elif re.search('_list',option):
            value = value.split(',')
        elif re.search('_dict',option):
            value = eval(value.strip())
        elif re.search('count|port',option):
            value = int(value)
        return value
    def get_export_rule(self):
        config = ConfigParser.SafeConfigParser()
        config_file = os.path.join(current_dir,'../conf/export_rules.ini')
        config.read(config_file)
        sections = config.sections()
  
        self.rules = self.getConfigByRegToDict(config=config, para='rule.')
        
myLocalConfig = LocalConfig()   
if __name__=="__main__":
    
    
    print myLocalConfig
    #print myLocalConfig.mysqlHosts

    #print myLocalConfig.remoteRedis